<template>
  <div class="index">
    <div class="container">
      <!-- main 头部 -->
      <el-container>
        <el-aside width="150px">
          <el-menu
            router
            :default-active="$route.path"
            class="el-menu-vertical-demo"
            background-color="#404952"
            text-color="#fff"
            active-text-color="#ffdd33"
          >
            <el-menu-item index="/index/newgame">
              <i class="el-icon-view"></i>
              <span slot="title">最新游戏</span>
            </el-menu-item>
            <el-menu-item index="/index/adgame">
              <i class="el-icon-sunny"></i>
              <span slot="title">安卓游戏</span>
            </el-menu-item>
            <el-menu-item index="/index/iosgame">
              <i class="el-icon-position"></i>
              <span slot="title">IOS游戏</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>

      <!-- banner -->
      <div class="banner">
        <div class="banner_left">
          <el-carousel height="300px">
            <el-carousel-item>
               <img @click="goto()" src="../assets/img/index/swiper_1.jpg" alt="" />
              <span
                >《和平精英》高端局应该如何进行枪械的搭配选择及使用技巧</span
              >
            </el-carousel-item>
            <el-carousel-item>
              <img @click="goto()" src="../assets/img/index/swiper_2.png" alt="" />
              <span>剑荡八荒3V3 S4赛季FAQ</span>
            </el-carousel-item>
            <el-carousel-item>
              <img @click="goto()" src="../assets/img/index/swiper_3.jpg" alt="" />
              <span
                >王者荣耀：被天美删除变态技能的四个英雄，李白被删废，安琪拉最惨</span
              >
            </el-carousel-item>
            <el-carousel-item>
              <img @click="goto()" src="../assets/img/index/swiper_4.jpg" alt="" />
              <span>侍魂：胧月传说 策划直播回顾热点问题答疑</span>
            </el-carousel-item>
          </el-carousel>
        </div>
        <div class="banner_right">
          <div>
            <router-link
              target="_blank"
              to="/information"
              title="《和平精英》高端局应该如何进行枪械的搭配选择及使用技巧"
            >
              《和平精英》高端局应该如何进行枪械的搭配选择及使用技巧
            </router-link>
            <router-link
              target="_blank"
              to="/information"
              title="剑荡八荒3V3 S4赛季FAQ"
            >
              剑荡八荒3V3 S4赛季FAQ
            </router-link>
          </div>
          <ul>
            <li>
              <router-link target="_blank" to="/information">
                侍魂：胧月传说 策划直播回顾热点问题答疑
              </router-link>
              <span>2019-04-20 18:56:32</span>
            </li>
            <li>
              <router-link target="_blank" to="/information">
                口袋魔法精灵：如何玩转地图漫游
              </router-link>
              <span>2019-04-20 18:28:16</span>
            </li>
            <li>
              <router-link target="_blank" to="/information">
                《口袋魔法精灵》主宠强化攻略
              </router-link>
              <span>2019-04-20 18:27:08</span>
            </li>
          </ul>
        </div>
      </div>
      <!-- 热门游戏 -->
      <div class="hot-game">
        <div>
          <p>热门游戏</p>
        </div>
        <ul>
          <li>
            <div>
              <img src="../assets/img/index/hgame-1.jpg" alt="" />
            </div>
            <div>
              <div>
                <span>三生三世十里桃花</span>
                <span>安卓</span>
              </div>
               <router-link :to="{path:'/gamedetail',query:{id:4}}">立即下载</router-link>
            </div>
          </li>
          <li>
            <div>
              <img src="../assets/img/index/hgame-2.jpg" alt="" />
            </div>
            <div>
              <div>
                <span>王者荣耀</span>
                <span>安卓</span>
              </div>
             <router-link :to="{path:'/gamedetail',query:{id:11}}">立即下载</router-link>
            </div>
          </li>
          <li>
            <div>
              <img src="../assets/img/index/hgame-3.jpg" alt="" />
            </div>
            <div>
              <div>
                <span>和平精英</span>
                <span>安卓</span>
              </div>
              <router-link :to="{path:'/gamedetail',query:{id:54}}">立即下载</router-link>
            </div>
          </li>
        </ul>
      </div>
      <!-- 精品推荐+热门活动 -->
      <div class="game-active">
        <div class="goodgame">
          <div>
            <div>
              <p>精品推荐</p>
              <!-- <div>
                <span>网游</span>
                <span>BT版</span>
                <span>满VIP版</span>
              </div> -->
            </div>
            <div>
              <router-link to="/gamecenter">
                更多
                <i class="el-icon-zoom-in"></i>
              </router-link>
            </div>
          </div>
          <div>
            <div v-for="(item, i) in jpgame" :key="item.id">
              <router-link :to="{path:'/gamedetail',query:{id:item.id}}">
                <img :src="item.geme_pic" alt="" />
              </router-link>
              <div>
                <router-link :to="{path:'/gamedetail',query:{id:item.id}}">{{ item.game_name }}</router-link>
                <span>类型:{{ typename[i] }}</span>
                <div>
                  <router-link :to="{path:'/gamedetail',query:{id:item.id}}">下载游戏</router-link>
                </div>
              </div>
            </div>
           
          </div>
        </div>
        <div class="hot-active">
          <div>
            <p>热门活动</p>
            <router-link to="/information">
              更多
              <i class="el-icon-zoom-in"></i>
            </router-link>
          </div>
          <div>
            <router-link
              v-for="item in gamebpic"
              :key="item.id"
              :title="item.title"
              to="/information"
              ><img :src="item.pic" alt=""
            /></router-link>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      jpgame: { //保存精品游戏
        type_id: [],
      },
      typename: [], //保存游戏类型
      gamebpic: [], //保存大图
    };
  },
  mounted() {
    this.$http.indexApi.game_name({ page: 4, pagesize: 9 }).then((res) => {
      console.log("game", res);
      this.jpgame = res.data.data;
      // console.log("this.jpgame", this.jpgame);
      let type_id = [];
      for (let i = 0; i < 9; i++) {
        type_id.push(res.data.data[i].type_id);
        this.$http.indexApi.type({ type_id: type_id[i] }).then((res) => {
          // console.log("type:", res.data.data[0].typename);
          this.typename.push(res.data.data[0].typename);
        });
      }
    });
    // console.log("游戏类型:", this.typename);

    this.$http.indexApi.gamebpic({ page: 9, pagesize: 4 }).then((res) => {
      console.log(res);
      this.gamebpic = res.data.data;
    });
  },
   methods: {
     goto(){
      this.$router.push(`/information`)
    }
  },
};
</script>

<style src="../assets/css/reset1.css">
</style>
<style lang="scss">
.index {
  background-color: #f3f3f3;
  padding: 20px 0;
}
.container {
  width: 1200px;
  margin: 0 auto;
  background-color: #f3f3f3;
  > .el-container {
    background-color: #fff;
    padding-left: 10px;
    margin-bottom: 20px;
    > .el-aside {
      height: 170px;
    }
    > .el-main {
      padding-bottom: 0;
    }
  }
  > .banner {
    display: flex;
    background-color: #fff;
    justify-content: space-between;
    height: 310px;
    margin-bottom: 20px;
    .banner_left {
      width: 49%;
      img {
        width: 100%;
        height: 310px;
      }
      position: relative;
      text-align: center;

      span {
        // position: absolute;
        color: #ffe825;
        font-size: 16px;
        padding: 10px 50px;
        background-image: linear-gradient(
          to right,
          rgba(0, 0, 0, 0.5),
          rgba(0, 0, 0, 0.8)
        );
        bottom: 0;
      }
    }
    .banner_right {
      // background-color: yellow;
      width: 49%;
      padding: 20px;
      > div {
        text-align: center;
        border-bottom: 1px dotted gray;
        > a {
          display: block;
          color: red;
          font-size: 25px;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          margin-bottom: 20px;
        }
      }
      > ul {
        height: 200px;
        // background-color: red;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        > li {
          font-size: 16px;
          padding: 10px;
          display: flex;
          justify-content: space-between;
        }
      }
    }
  }
  > .hot-game {
    padding: 10px;
    margin-bottom: 20px;
    background-color: #fff;
    > div {
      border-bottom: 2px solid #e4e4e4;
      height: 48px;
      > p {
        height: 48px;
        line-height: 48px;
        display: inline-block;
        color: #ff6100;
        font-size: 25px;
        border-bottom: 2px solid #ff6100;
      }
      > div {
        height: 67px;
      }
    }
    > ul {
      margin-top: 20px;
      display: flex;
      justify-content: space-between;
      > li {
        width: 378px;
        > div:first-child {
          overflow: hidden;
          > img {
            width: 100%;
            transition: 1s;
            &:hover {
              transform: scale(1.05);
            }
          }
        }
        > div:last-child {
          display: flex;
          padding: 20px;
          background-color: #fafafa;
          justify-content: space-between;
          align-items: center;
          > div {
            font-size: 16px;
            > span {
              margin-right: 15px;
              &:first-child {
                color: #666;
                font-weight: bold;
              }
              &:last-child {
                font-size: 14px;
                padding: 0 10px;
                color: #fff;
                background-color: #52be7f;
              }
            }
          }
          > a {
            border: 1px solid #ff5353;
            color: #ff5353;
            padding: 5px 20px;
            border-radius: 20px;
            transition: 0.2s;
            &:hover {
              color: #fff;
              background-color: #ff5353;
            }
          }
        }
      }
    }
  }
  .game-active {
    background-color: #fff;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    > .goodgame {
      width: 60%;
      // background-color: red;
      > div:first-child {
        height: 48px;
        border-bottom: 2px solid #e4e4e4;
        padding: 10px;
        padding-left: 0;
        padding-bottom: 0;
        // background-color: yellow;
        display: flex;
        justify-content: space-between;
        align-items: center;
        > div:first-child {
          // background-color: blue;
          width: 70%;
          display: flex;
          justify-content: space-between;
          align-items: end;
          > P {
            height: 48px;
            line-height: 48px;
            display: inline-block;
            color: #ff6100;
            font-size: 25px;
            border-bottom: 2px solid #ff6100;
          }
          > div {
            text-align: center;
            span {
              display: inline-block;
              padding: 5px 0;
              width: 100px;
              font-size: 16px;
              margin-right: 1px;
              border: 1px solid #f4f4f4;
              border-bottom: none;
              position: relative;
              top: -1px;
              cursor: pointer;
              background-color: #f4f4f4;
              &:hover {
                background-color: #fff;
                color: #ff6152;
                border-bottom: none;
                border-top: 5px solid #f4f4f4;
              }
            }
          }
        }
        > div:last-child {
          a {
            color: #8b8b8b;
            &:hover {
              color: #ff9758;
            }
            > i {
              font-size: 16px;
              position: relative;
              top: 2px;
            }
          }
        }
      }
      > div:last-child {
        display: flex;
        flex-wrap: wrap;
        padding-top: 20px;
        > div {
          display: flex;
          width: 33%;
          margin-bottom: 20px;
          > a {
            margin-right: 15px;
            img {
              width: 80px;
            }
          }
          > div {
            width: 120px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            > a:first-child {
              font-size: 16px;
              color: black;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }
            > span {
              color: #999;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
              font-size: 12px;
            }
            > div {
              a {
                text-align: center;
                padding: 2px;
                position: relative;
                top: -5px;
                left: 20px;
                padding: 2px 10px;
                border-radius: 10px;
                color: #4badff;
                border: 1px solid #4badff;
                transition: 0.2s;
                &:hover {
                  background-color: #4badff;
                  color: #fff;
                }
              }
            }
          }
        }
      }
    }
    > .hot-active {
      // background-color: red;
      width: 38%;
      > div:first-child {
        height: 48px;
        border-bottom: 2px solid #e4e4e4;
        padding: 10px;
        padding-left: 0;
        padding-bottom: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        > p {
          height: 48px;
          line-height: 48px;
          display: inline-block;
          color: #ff6100;
          font-size: 25px;
          border-bottom: 2px solid #ff6100;
        }
        > a {
          color: #8b8b8b;
          &:hover {
            color: #ff9758;
          }
          > i {
            font-size: 16px;
            position: relative;
            top: 2px;
          }
        }
      }
      > div:last-child {
        margin-top: 20px;
        padding-top: 10px;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        a {
          margin-bottom: 20px;
            width: 220px;
          img {
            width: 100%;
            height: 100%;
            border-radius: 20px;
          }
        }
      }
    }
  }
}
.aside::-webkit-scrollbar {
  display: none;
}
</style>
